<?php
/*
 * @Descripttion: 
 * @version: 1.0
 * @Author: Sam
 * @Date: 2022-04-21 15:27:12
 * @LastEditors: Sam
 * @LastEditTime: 2022-04-28 16:24:34
 */
use think\facade\Db;
use app\admin\model\AuthRule as AuthRuleModel;
if (!AuthRuleModel::where('title', '抽奖管理')->count()) {

    $parent_id = AuthRuleModel::query()->create([
        'parent_id'    => 0,
        'title'        => '抽奖管理',
        'url'          => '#',
        'method'       => 'OPTIONS',
        'slug'         => 'prize'
    ]);
   $parent_id_1 =   AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '奖品列表',
        'url'          => 'prize_index',
        'method'       => 'GET',
        'slug'         => 'prize.index'
    ]);
    $parent_id_2 =   AuthRuleModel::query()->create([
        'parent_id'    => $parent_id->id,
        'title'        => '中奖记录',
        'url'          => 'prize_log',
        'method'       => 'GET',
        'slug'         => 'prize.prize_log'
    ]);
   AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_2->id,
        'title'        => '中奖记录导出',
        'url'          => 'prize_log_export',
        'method'       => 'GET',
        'slug'         => 'prize.prize_log_export'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_1->id,
        'title'        => '添加',
        'url'          => 'prize_create',
        'method'       => 'POST',
        'slug'         => 'prize.create'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_1->id,
        'title'        => '编辑奖品',
        'url'          => 'prize_edit',
        'method'       => 'POST',
        'slug'         => 'prize.edit'
    ]);
    AuthRuleModel::query()->create([
        'parent_id'    => $parent_id_1->id,
        'title'        => '删除奖品',
        'url'          => 'prize_delete',
        'method'       => 'POST',
        'slug'         => 'prize.delete'
    ]);
}
